package contacts530.service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import contacts530.dao1.IStudentsDao;
import contacts530.dao1.impl.StudentsDaoImpl;
import contacts530.po.Room;
import contacts530.po.Students;
public class ContactService {
private static IStudentsDao studentDao =new StudentsDaoImpl(); //数据库存储
private Students name;
private IStudentsDao roomDao;
//文件存储对象 controller中删除功能代码需修改。
/**
 * 查找通讯录
 *  * @param studentList 被查询的集合
 * @param student 需要查询的通讯录
 */ 
public List<Students> searchByPrice(List<Students> studentList,Students student) {
	List<Students> result = new ArrayList<Students>(); //查询结果集
	Collections.sort(studentList);
	int m = -1;
	while ((m = Collections.binarySearch(studentList,student, null)) >= 0) {
		Students bk = studentList.get(m);
		studentList.remove(m);
		result.add(bk);
	}
	return result;
}
/**
 * 修改学生信息
 * @param id
 * @param book
 */
public void updateStudent(Students student) {
	studentDao.update(name);
	
}
/**
 * 删除学生信息
 * @param name
 */
public void deleteStudents(String name) {
	studentDao.delete(name);	
}
/**
 * 查询学生信息
 * @param name
 * @return
 */
public static Students getStuden(String name) {
	return studentDao.get(name);
}
/**
 * 查询所有学生
 * @return
 */
public List<Students> findAllStudent(){ 
	return studentDao.findAll();
	
}
public List<Room> findAllRoom(){ 
	return roomDao.findAllRoom();
	
}
/**
 * @param selRow
 * @param updatedStudents
 */
public void updateStudents(int selRow, Students updatedStudents) {
	// TODO Auto-generated method stub
	
}
public void addStudents(Students student) {
	studentDao.save(student);// TODO Auto-generated method stub	
}
/**
 * 添加学生信息
 */
public void addStudents(Object newStudents) {
	// TODO Auto-generated method stub	
}
}


